package com.jack.thinking.thread.core._1;

import java.util.Random;

public class PriorityEffect {
	public static void main(String[] args) {
		for (int i = 0; i < 5; i++) {
			Thread t = new MyThreadPriorityA();
			t.setPriority(1);
			t.start();
			Thread t1 = new MyThreadPriorityB();
			t1.start();
			t1.setPriority(10);
		}
	}
}

class MyThreadPriorityA extends Thread{
	@Override
	public void run() {
		long begin = System.currentTimeMillis();
		for (int i = 0; i < 1000000; i++) {
			Random random = new Random();
			random.nextInt();
		}
		long end = System.currentTimeMillis();
		System.out.println("******** thread A use time: " + (end - begin));
	}
}


class MyThreadPriorityB extends Thread{
	@Override
	public void run() {
		long begin = System.currentTimeMillis();
		for (int i = 0; i < 1000000; i++) {
			Random random = new Random();
			random.nextInt();
		}
		long end = System.currentTimeMillis();
		System.out.println("------- thread B use time: " + (end - begin));
	}
}